Ext.namespace('GBIF');
Ext.namespace('GBIF.GeoSpatial');

GBIF.GeoSpatial.GeoRssDataPanel = function(config){
	
 		var map = new GBIF.GeoSpatial.MapComponent({
				region:'center'
		});
		
		var sundials = new OpenLayers.Layer.GML(
					"Sundials"
				, 	"../resources/api/getcapabilities-proxy.php?url=http://bioval.jrc.ec.europa.eu/APAAT/alerts/alert_list_latest.xml?"
				,	{
							format: OpenLayers.Format.KML
						,	formatOptions: {
									extractStyles: true
								,	extractAttributes: true
								,	maxDepth: 2
							}
					}
			);
		map.map.addLayer(sundials);

		var store = new GeoExt.data.FeatureStore({
    			layer: sundials
    		,	proxy: new GeoExt.data.ProtocolProxy({
		        			protocol: new OpenLayers.Protocol.HTTP({
				            		url: "../resources/api/getcapabilities-proxy.php?urlhttp://bioval.jrc.ec.europa.eu/PA/alerts.kml?"
						        ,   format: new OpenLayers.Format.KML()
						        })
    				})
    		,	fields: [
        				{name: 'name', type: 'string'}
        			,	{name: 'description', type: 'string'}
					,	{name: 'coordinates', type: 'coordinates'}
    				]
    		,	autoLoad: true
		});


	var grid = new Ext.grid.GridPanel({
				    title: 'Sundials'
			    ,	store: store
				,   columns: [
								{heading: 'name', dataIndex: 'name'}
							,	{heading: 'Description', dataIndex: 'description'}
							,	{heading:'coordinates', dataIndex: 'coordinates'}
							]
				,   width: 500
				,   height: 600
				,	region:'east'
			});

	
	
	
	Ext.apply(this,config,{
			title: "Map"
        ,	height: 600
        ,	width: 800
    	,	layout:'border'
		,	items:[map,grid]
	})
	GBIF.GeoSpatial.GeoRssDataPanel.superclass.constructor.call(this, config)
}
Ext.extend(GBIF.GeoSpatial.GeoRssDataPanel, GeoExt.MapPanel, {
	
})
